﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;

namespace _42_Kicks
{
    class Healthbar
    {

        //Variables
        //private SpriteBatch spriteBatch;
        //private GraphicsDevice graphicsDevice;

        private Vector2 position;
        private Vector2 dimension;

        private float ValMax;
        private float ValActuelle;

 
        //CONSTRUCTEURS
        public Healthbar(Vector2 position, Vector2 dimension, float ValMax, SpriteBatch spriteBatch, GraphicsDevice graphicsDevice)
        {
            this.position = position;
            this.dimension = dimension;
            this.ValMax = ValMax;
            
        }


        

        public void update(float ValActuelle)
        {
            this.ValActuelle = ValActuelle;
        }

        public void DrawHeroPV(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice, Heros heros)
        {
                ValActuelle = heros.pointdevie;
                float pourcent = ValActuelle / ValMax; 
            
            //Couleurs de la barre et du fond de la barre
            Color Barre = new Color(0, 85, 0, 255);
            Color FondBarre = new Color(63, 200, 100, 200);
          
            //Définit la taille de la barre de vie
            Rectangle backgroundRectangle = new Rectangle();
            backgroundRectangle.Width = (int)dimension.X;
            backgroundRectangle.Height = (int)dimension.Y;
            backgroundRectangle.X = (int)position.X;
            backgroundRectangle.Y = (int)position.Y;

            //
            Texture2D Texture = new Texture2D(graphicsDevice, 1, 1);
            Texture.SetData(new Color[] { FondBarre });
            //Dessinne le fond
            spriteBatch.Draw(Texture, backgroundRectangle, FondBarre);


            

            backgroundRectangle.Width = (int)(dimension.X * pourcent);
            backgroundRectangle.Height = (int)(dimension.Y );
            backgroundRectangle.X = (int)position.X ;
            backgroundRectangle.Y = (int)position.Y ;

            Texture = new Texture2D(graphicsDevice, 1, 1);
            Texture.SetData(new Color[] { Barre });

            //Dessinne notre barre
            spriteBatch.Draw(Texture, backgroundRectangle, FondBarre);

        }

        
        }


    }

